<!-- Copyright (c) 2022 渝州大数据实验室
 *
 * Lanius is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 -->
<!-- 
* @desc:任务编排卡片列表组件
* @fileName:TaskArrangementCards.vue
* @author:zoujunjie@yzbdl.ac.cn
* @date:2022-4-20
!-->
<template>
  <Card
    v-for="item in displayCardList"
    :key="item.key + ''"
    :figure="item.figure"
    :icon-url="item.iconUrl"
    :note="item.text"
    :target-url="item.targetUrl"
    :tag-color="item.color"
  ></Card>
</template>

<script setup lang="ts">
import Card from "./Card.vue";
import { ComputedRef, computed } from "vue";
import {
  CardItemModel,
  TaskItemData,
  getTaskArrangementDefaultList,
} from "@/services/task-schedule/dashboard";

//组件参数定义
interface Props {
  //任务实例数据
  data?: TaskItemData[];
}

const props = defineProps<Props>();

let cardList: CardItemModel[] = getTaskArrangementDefaultList();

const displayCardList: ComputedRef<CardItemModel[]> = computed(
  (): CardItemModel[] => {
    return cardList.map((item) => {
      let foundItem = props.data?.find((x) => x.status + "" == item.key);
      if (foundItem) {
        item.figure = foundItem.count + "";
      }
      return item;
    });
  }
);
</script>

<style scoped lang="scss"></style>
